<template>
  <view class="container">
    <uni-card title="收益列表" :isFull="true" type="line" padding="0px" spacing="0px">
      <!-- <template #extra> <view @click="onMore">查看更多</view> </template> -->
      <uni-list>
        <uni-list-item :ellipsis="1" v-for="item in dates" :rightText="item.income" clickable :title="item.time" />
      </uni-list>
    </uni-card>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';

const queryForm = {
  pageNum: 1,
  pageSize: 5,
  searchCount: false,
};

const dates = ref([]);
function getLastTenDays() {
  dates.value = [];
  const today = new Date();

  for (let i = 0; i < 10; i++) {
    const date = new Date(today);
    date.setDate(today.getDate() - i); // 往回推i天

    const year = date.getFullYear();
    let month = date.getMonth() + 1; // getMonth() 返回0-11
    let day = date.getDate();

    // 确保月份和日子都是两位数
    month = month < 10 ? '0' + month : month;
    day = day < 10 ? '0' + day : day;

    let income = {};
    income.time = `${year}-${month}-${day}`;
    income.income =  getRandomFloat(50, 120);

    dates.value.push(income);
  }

}

function getRandomFloat(min, max) {
  return (Math.random() * (max - min) + min).toFixed(2);
}

onShow(() => {
  getLastTenDays();
});

</script>

<style lang="scss" scoped>
.container {
  width: 700rpx;
  margin: 0 auto 20rpx;
  border-radius: 12rpx;
  padding: 0;
  overflow: hidden;

  :deep(.uni-card__header-box) {
    font-weight: bold;
  }

  :deep(.uni-list--border-bottom) {
    background-color: transparent;
  }

  :deep(.uni-card__content) {
    padding: 0 !important;
  }

  :deep(.uni-card__header) {
    border: none;
  }

  :deep(.uni-card .uni-card__header .uni-card__header-content .uni-card__header-content-title) {
    font-size: 32rpx;
  }

  :deep(.uni-list-item__container) {
    padding: 16rpx 20rpx;
  }

  :deep(.uni-card__header) {
    background: linear-gradient(180deg, #e8f4ff, #f8fcff);
  }

  :deep(.uni-card__header-extra) {
    font-size: 30rpx;
    font-weight: 400;
    text-align: center;
    color: #1a9aff;
  }

  :deep(.uni-list-item__content-title) {
    font-size: 30rpx;
  }
}
</style>
